package com.yc.thread;

/***
 * join操作
 */
public class Test13_join {
    //main线程
    public static void main(String[] args) throws InterruptedException{
        LifeCircle lc=new LifeCircle();
        System.out.println(lc.isAlive());//线程状态值
        lc.start();
        System.out.println(lc.isAlive());

        lc.join();  //TODO: 让lc先运行完 再执行main

        System.out.println("主程序的其他操作");
        System.out.println(lc.isAlive());

    }
}

class LifeCircle extends Thread{
    @Override
    public void run(){
        int i=0;
        while ((++i)<10){
            System.out.println(Thread.currentThread().getName()+":"+i);
            try{
                Thread.sleep(1000);
            }catch (InterruptedException e){
                e.printStackTrace();
            }
        }
    }
}
